<?php

class Control_Model_Table_SubPageContent extends Zend_Db_Table_Abstract {

    protected $_name = 'dynamic_content';

    public function getPageContent($page) {

        $select = $this->select();
        $select->order('id DESC')
                ->where('id_page=?', $page);
        $content = $this->_db->query($select)->fetchAll();
        return $content;
    }

        public function getAllPages() {
        $select = $this->select();
        $select->order('id DESC');
        $subPage = $this->_db->query($select)->fetchAll();
        return $subPage;
    }

        public function insertPageContent($id_page, $content) {
        $data = array(
            'id_page' => $id_page,
            'content' => $content
        );
        $this->insert($data);
    }

        public function getPageContentID($id) {

        $select = $this->select();
        $select->order('id DESC')
                ->where('id=?', $id);
        $content = $this->_db->query($select)->fetchAll();
        return $content;
    }

            public function updateContent($id, $id_page, $content)
    {
        $data = array(
            'id_page' => $id_page,
            'content' => $content
        );
        $this->update($data, 'id = '. (int)$id);
    }

            public function deleteContent($id)
    {
        $this->delete('id =' . (int)$id);
    }

}

